<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<fmt:setBundle basename="messages"/>
<script language="javascript">
	var conUnit = <bean:write name="CON_UNIT"/>;
	var tonsUnit = 1/conUnit;
	var futuresUnit = 1;
	function sumFutures(forma){
		var futures = forma.futures;
   		var tons = forma.tons;
		var futureQuantity = forma.futuresQuantity;
		var futuresSum = 0;
		if( futureQuantity.length == undefined ){
			futuresSum = parseFloat(futureQuantity.value.replace(/,/g, ""));
		}else{
			for (i = 0; i < futureQuantity.length; i++){
				if( trim(futureQuantity[i].value) != "" ){
					futuresSum = futuresSum + parseFloat(futureQuantity[i].value.replace(/,/g, ""));
				}
			}
		}
		futures.value = addCommas(futuresSum);
		tons.value = addCommas(decimales( futuresSum/conUnit,2 ));
	}
	
	function sumQuantity(forma){
	
   		var quantityItem = forma.itemQuantity;
   		var quantityCornItem = forma.cornQuantity;
   		var quantityFuturesFlooredtotal = forma.futFlooredTotal;
   	   	
   		var quantity = 0;
   		var quantityCorn = 0;
   		var futuresFlooredTotal = 0;
   		
   			
   		var checks = forma.instructionForecastCheck;
   		
   		var  inc = forma.quantity;
   		var  inc2 = forma.quantityCorn;
   		var  inc3 = forma.futuresFlooredTotal;
   		   		
   		for (i = 0; i < checks.length; i++){
      		if (checks[i].checked){      		
        		quantity = quantity + parseFloat(inc[i].value.replace(/,/g, ""));
        		quantityCorn = quantityCorn + parseFloat(inc2[i].value.replace(/,/g, ""));
        		futuresFlooredTotal = futuresFlooredTotal + parseFloat(inc3[i].value);
      		}
		}
		
		quantityItem.value = addCommas( decimales( quantity, 2 ) );
		quantityCornItem.value = addCommas( decimales( quantityCorn, 2 ) );
		quantityFuturesFlooredtotal.value = addCommas(parseInt(futuresFlooredTotal+.99));
		
	}

	function validateForm(forma){
		var retVal = false;
		var errors = '';
		var futures = forma.futuresQuantity;
		var montSug = forma.montSugQuantity;
		var stopLoss = forma.stopLossQuantity;
		var futuresLength = futures.length;
		var strategyId = document.getElementById("instructionPurchaseDetailView.instructionStrategyId").value;
		
		var tons = forma.tons.value.replace(/,/g, "");
		var cornQuantity = forma.cornQuantity.value.replace(/,/g, "");
		
		futuresUnit = (parseFloat(conUnit)*parseFloat(cornQuantity))+.99;

		if(parseFloat(tons) > (parseFloat(cornQuantity)+parseFloat(tonsUnit))){
			errors = errors + ' - <bean:message key="label.purchases.instructions.detail.wrongfuturesnumber"/>';
			errors = errors + ' : <'+parseInt(futuresUnit) +'>\n';
		}


		for( var index = 0; index < futuresLength; index++ ){
			if( trim(futures[index].value) != ''  || trim(montSug[index].value) != ''  ){
				if( trim(futures[index].value) == '' || (trim(montSug[index].value) == ''&& strategyId != "1" )){
					errors = errors + '\t<bean:message key="label.purchases.instructions.line"/> '+(index+1)+' :\n';
					if( trim(futures[index].value) == '' ){
						errors = errors +  '\t\t<bean:message key="error.purchases.instructions.future.requiered"/>\n';
					}
					if( trim(montSug[index].value) == '' ){
						if( strategyId != "1" ){
							errors = errors +  '\t\t<bean:message key="error.purchases.instructions.sug.amount"/>\n';
						}
					}else{
						if( parseFloat( montSug[index].value.replace(/,/g, "") ) > parseFloat( stopLoss[index].value.replace(/,/g, "") ) ){
							errors = errors +  '\t\t<bean:message key="error.purchases.instructions.sug.amount.minus.to.stop.loss"/>\n';
						}
					}
				}else{
					if( trim(montSug[index].value) != '' ){
						if( parseFloat( montSug[index].value.replace(/,/g, "") ) > parseFloat( stopLoss[index].value.replace(/,/g, "") ) ){
							errors = errors +  '\t<bean:message key="label.purchases.instructions.line"/> '+(index+1)+' :\n\t\t<bean:message key="error.purchases.instructions.sug.amount.minus.to.stop.loss"/>\n';
						}
					}
				}
			}
		}
		if( errors != '' ){
			alert( '<bean:message key="label.common.errors"/> : \n' + errors );
		}else{
			retVal = true;
		}
		return retVal;
	}

	function cleanValues(row){   			  			
			if(document.InstructionPurchaseDetailForm.futuresQuantity.length != undefined){
				document.InstructionPurchaseDetailForm.futuresQuantity[row].value = "";
				document.InstructionPurchaseDetailForm.montSugQuantity[row].value = "";
				document.InstructionPurchaseDetailForm.stopLossQuantity[row].value = "";
				document.InstructionPurchaseDetailForm.accountFuturePeriodIdSelect[row].selectedIndex = 0;
				document.InstructionPurchaseDetailForm.applicationFuturePeriodIdSelect[row].selectedIndex = 0;
				document.InstructionPurchaseDetailForm.minorPriceSelect[row].selectedIndex = 0;
				sumFutures(document.InstructionPurchaseDetailForm);
			}
		}
</script>
<html:form action="/purchaseInstructionDetailsUpdate" styleId="mainForm" onsubmit="return validateForm(this);">
<html:hidden property="ipdView.purchaseInstructionId"/>
	<table width="99%" align="center"  border="0">
		<tr>
			<td colspan="2" >
				<table width="100%" align="right" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>	
						<td align="left" class="titulocolumna">
							<bean:message key="label.purchases.instructions.edit.commitment.purchase"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<table width="100%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td class="titulocolumna" align="center" width="2%">
							<fmt:message key="label.purchaseinstructiondetail.line" />
						</td>
						<td class="titulocolumna" align="center" width="31%">
							<fmt:message key="label.purchaseinstructiondetail.customer" />
						</td>
						<td class="titulocolumna" align="center" width="27%">
							<fmt:message key="label.purchaseinstructiondetail.product" />
						</td>				
						<td class="titulocolumna" align="center" width="9%">
							<fmt:message key="label.purchaseinstructiondetail.type" />
						</td>
						<td class="titulocolumna" align="center" width="9%">
							<fmt:message key="label.purchaseinstructiondetail.purchase.strategy" />
						</td>
						<td class="titulocolumna" align="center" width="14%">
							<fmt:message key="label.purchaseinstructiondetail.type.strategy" />
						</td>
						<td class="titulocolumna" align="center" width="8%">
							<fmt:message key="label.purchaseinstructiondetail.status" />
						</td>
					</tr>
					<tr class="columnadatoPar">
						<td align="center" valign="top">
							<html:hidden property="ipdView.purchaseInstructionDetailid"/><bean:write property="ipdView.row" name="InstructionPurchaseDetailForm" />
						</td>
						<td align="left" valign="top">
							<bean:write property="ipdView.customerView.customerId" name="InstructionPurchaseDetailForm" /> - <bean:write property="ipdView.customerView.description" name="InstructionPurchaseDetailForm" /><html:hidden property="ipdView.customerView.description" />							
						</td>
						<td align="left">
							<table width="99%" align="center" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
								<c:forEach items="${InstructionPurchaseDetailForm.ipdView.productList}" var="productos" varStatus="loopInside">
									<tr class='<c:choose><c:when test="${loopInside.index%2 == 0}"><c:out value="columnadatoPar" /></c:when><c:otherwise><c:out value="columnadatoNon" /></c:otherwise></c:choose>'>
										<td align="center">
											<c:out value="${productos.productId}"></c:out>
										</td>
										<td align="left">
											<c:out value="${productos.shortDescription}"></c:out>
										</td>
									</tr>
								</c:forEach>
							</table>
						</td>
						<td valign="top">
							<c:choose>
								<c:when test="${not READ_ONLY}">
									<html:select property="ipdView.futureTypeId" styleId="ipdView.futureTypeId" styleClass="campo_texto">
										<html:option value="D"><bean:message key="label.futuretype.D"/></html:option>
										<html:option value="F"><bean:message key="label.futuretype.F"/></html:option>					
									</html:select>
								</c:when>
								<c:otherwise>
									<fmt:message key="label.futuretype.${InstructionPurchaseDetailForm.ipdView.futureTypeId}"></fmt:message>
								</c:otherwise>
							</c:choose>
						</td>
						<td valign="top">
							<c:choose>
								<c:when test="${not READ_ONLY}">
									<html:select property="ipdView.instructionStrategyId" styleId="ipdView.instructionStrategyId" styleClass="campo_texto">
										<html:option value="1"><bean:message key="label.strategyid.1"/></html:option>
										<html:option value="2"><bean:message key="label.strategyid.2"/></html:option>
										<html:option value="3"><bean:message key="label.strategyid.3"/></html:option>
										<html:option value="4"><bean:message key="label.strategyid.4"/></html:option>
									</html:select>
								</c:when>
								<c:otherwise>
									<fmt:message key="label.strategyid.${InstructionPurchaseDetailForm.ipdView.instructionStrategyId}"></fmt:message>
								</c:otherwise>
							</c:choose>
						</td>
						<td valign="top">
							<c:choose>
								<c:when test="${not READ_ONLY}">
									<html:select property="ipdView.instructionTypeId" styleId="ipdView.instructionTypeId" styleClass="campo_texto">
										<html:option value="1"><bean:message key="label.strategytypeid.1"/></html:option>
										<html:option value="2"><bean:message key="label.strategytypeid.2"/></html:option>
										<html:option value="3"><bean:message key="label.strategytypeid.3"/></html:option>
										<html:option value="4"><bean:message key="label.strategytypeid.4"/></html:option>
									</html:select>
								</c:when>
								<c:otherwise>
									<fmt:message key="label.strategytypeid.${InstructionPurchaseDetailForm.ipdView.instructionTypeId}"></fmt:message>
								</c:otherwise>
							</c:choose>
						</td>
						<td valign="top">
							<c:choose>
								<c:when test="${not READ_ONLY}">
									<html:select property="ipdView.status" styleId="ipdView.status" styleClass="campo_texto">
										<html:option value="1"><bean:message key="label.purchaseinstructiondetail.status.1"/></html:option>
										<html:option value="2"><bean:message key="label.purchaseinstructiondetail.status.2"/></html:option>
										<html:option value="3"><bean:message key="label.purchaseinstructiondetail.status.3"/></html:option>
									</html:select>	
								</c:when>
								<c:otherwise>
									<fmt:message key="label.purchaseinstructiondetail.status.${InstructionPurchaseDetailForm.ipdView.status}"></fmt:message>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
					</table>
			</td>
		</tr>
		<tr>
			<td width="40%" align="right" valign="top">
				<table width="95%" align="right" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>					
						<td colspan="7" align="center" class="titulocolumna">
							<bean:message key="label.purchases.instructions.edit.commitment.purchase.detail"/>
						</td>
					</tr>
					<tr class="columnadatopar">
						<td align="right" colspan="2">
							<fmt:message key="label.instructionsforecast.totals"/>
						</td>					
						<td align="right">
							<c:choose>
								<c:when test="${not READ_ONLY}">
									<html:text styleId="itemQuantity" property="ipdView.itemQuantity" readonly="true" size="8" styleClass="campo_texto_r"/>
								</c:when>
								<c:otherwise>
									<bean:write name="InstructionPurchaseDetailForm" property="ipdView.itemQuantity"/>
								</c:otherwise>
							</c:choose>
						</td>
						<td align="right">
							<c:choose>
								<c:when test="${not READ_ONLY}">
									<html:text styleId="cornQuantity" property="ipdView.cornQuantity" readonly="true" size="8" styleClass="campo_texto_r"/>
								</c:when>
								<c:otherwise>
									<bean:write name="InstructionPurchaseDetailForm" property="ipdView.cornQuantity"/>
								</c:otherwise>
							</c:choose>
						</td>
						<td colspan="3" align="left">
							<input type="text" id="futFlooredTotal" value="" class="campo_texto_r" size="2"/>
						</td>
					</tr>
					<tr>
						<td class="titulocolumna" align="center" width="4%">&nbsp;</td>
						<td class="titulocolumna" align="center" width="16%">
							<fmt:message key="label.instructionsforecast.period"/>
						</td>	
						<td class="titulocolumna" align="center" width="17%">
							<fmt:message key="label.instructionsforecast.quantity"/>
						</td>	
						<td class="titulocolumna" align="center" width="20%">
							<fmt:message key="label.instructionsforecast.quantity.corn"/>
						</td>	
						<td class="titulocolumna" align="center"  colspan="2">
							<fmt:message key="label.instructionsforecast.futures"/>
						</td>	
						<td class="titulocolumna" align="center" width="17%">
							<fmt:message key="label.instructionsforecast.current"/>
						</td>
					</tr>
					<c:forEach items="${InstructionPurchaseDetailForm.instructionsForecastsDetailView.details}" var="detail" varStatus="loop">
						<input type="hidden" id='quantity'  name='quantity' value='<c:out value="${detail.contracted}" />'/>
						<input type="hidden" id='quantityCorn' name='quantityCorn' value='<c:out value="${detail.cornContracted}" />'/>
						<input type="hidden" id='futuresFlooredTotal' name='futuresFlooredTotal' value='<c:out value="${detail.futures}" />'/>
						<tr class='<c:choose><c:when test="${loop.index%2 == 0}"><c:out value="columnadatoPar" /></c:when><c:otherwise><c:out value="columnadatoNon" /></c:otherwise></c:choose>'>
							<td>
								<c:choose>
									<c:when test="${not READ_ONLY}">
										<input type='checkbox' onclick="sumQuantity(this.form)" id="instructionForecastCheck" name='instructionsForecastsDetailView.checked'  <c:if test="${detail.forecastAdded==1}" ><c:out value="checked"/></c:if> value='<c:out value="${loop.index}"/>' />
									</c:when>
									<c:otherwise>
										<img alt="" src="images/selected<c:out value="${detail.forecastAdded}"/>.png" border="0" height="12" width="12">
									</c:otherwise>
								</c:choose>
							</td>
							<td align="center">
								<a href="showForecastByPeriodFromEditMod.do?month=<c:out value="${detail.month}" />&year=<c:out value="${detail.year}" />&customerId=<c:out value="${detail.customerId}" />&instructionPurchaseDetailId=<c:out value="${InstructionPurchaseDetailForm.ipdView.purchaseInstructionId}" />">			
									<c:out value="${detail.year}" />.<fmt:formatNumber maxIntegerDigits="2" minIntegerDigits="2" pattern="##" value="${detail.month}"></fmt:formatNumber>
								</a>
							</td>
							<td align="right"><c:out value="${detail.contracted}" /></td>
							<td align="right"><c:out value="${detail.cornContracted}" /></td>
							<td align="right" width="10%"><c:out value="${detail.futuresFloored}" /></td>
							<td align="right" width="14%">(<c:out value="${detail.futures}" />)</td>
							<td align="right"><c:if test="${detail.forecastAdded==1}" ><c:out value="${detail.actual}" /></c:if></td>
						</tr>
					</c:forEach>
					</table>
			</td>
			<td width="60%" align="left" valign="top">
				<table width="450px" align="left" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td colspan="8" align="center" class="titulocolumna">
							<bean:message key="label.purchases.instructions.label"/>
						</td>
					</tr>
					<tr class="columnadatopar" align="right">
						<td align="right" colspan="2">
							<html:text styleId="futures" property="ipdView.futures" readonly="true"  size="3" styleClass="campo_texto_r"/>
							<html:hidden styleId="tons" property="ipdView.tons" />
						</td>
						<td align="left" colspan="6">
							<fmt:message key="label.instructionsforecast.totals"/>
						</td>
					</tr>
					<tr>
						<td class="titulocolumna">
							&nbsp;
						</td>
						<td class="titulocolumna">
							<bean:message key="menu.module.corn.sub.future"/>
						</td>
						<td class="titulocolumna">
							<bean:message key="label.purchases.instructions.futures.price"/>												
						</td>
						<td class="titulocolumna">
							<bean:message key="label.purchases.instructions.futures.furchase.period"/>
						</td>
						<td class="titulocolumna">
							<bean:message key="label.purchases.instructions.futures.furchase.application"/>												
						</td>
						<td class="titulocolumna">
							<bean:message key="label.purchases.instructions.futures.minor.price"/>												
						</td>
						<td class="titulocolumna">
							<bean:message key="label.purchases.instructions.futures.stoploss"/>								
						</td>
						<td class="titulocolumna">
							&nbsp;
						</td>
					</tr>		
					<logic:notEmpty name="InstructionPurchaseDetailForm" property="instructionsFuturesView">
						<logic:iterate id="row" name="InstructionPurchaseDetailForm" property="instructionsFuturesView" indexId="int_i">
							<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">
								<html:hidden name="row" property="purchaseInstructionFutureId"/>
								<html:hidden name="row" property="purchaseInstructionDetailId"/>
								<td align="center">
									<%=int_i.intValue()+1%>
								</td>					
								<td align="right">
									<input type="hidden" style="text-align: right;" name='instructionsFuturesView[<c:out value="${int_i}"/>].purchaseInstructionDetailId' value='<c:out value="${row.purchaseInstructionDetailId}"/>' />
									<c:choose>
										<c:when test="${not READ_ONLY}">
											<input type="text" style="text-align: right;" onblur="sumFutures(this.form)"  id="futuresQuantity" name='instructionsFuturesView[<c:out value="${int_i}"/>].quantity'  value='<logic:notEqual name="row" property="quantity" value="0"><c:out value="${row.quantity}"/></logic:notEqual>' class="campo_texto" onfocus="this.select();" onkeydown="return (numeric(event, 0) && noPaste(event, this));" onkeyup="extractNumber(this,2,false);" size="3">
										</c:when>
										<c:otherwise>
											<input type="hidden" id="futuresQuantity" name='instructionsFuturesView[<c:out value="${int_i}"/>].quantity'  value='<logic:notEqual name="row" property="quantity" value="0"><c:out value="${row.quantity}"/></logic:notEqual>'>
											<logic:notEqual name="row" property="quantity" value="0"><c:out value="${row.quantity}"/></logic:notEqual>
										</c:otherwise>
									</c:choose>
								</td>
								<td align="right">
									<c:choose>
										<c:when test="${not READ_ONLY}">
											<input type="text" id="montSugQuantity" style="text-align: right;" name='instructionsFuturesView[<c:out value="${int_i}"/>].price' onfocus="this.select();" value='<logic:notEqual name="row" property="price" value="-1"><c:out value="${row.price}"/></logic:notEqual>'  class="campo_texto" onfocus="this.select();" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);" size="5">
										</c:when>
										<c:otherwise>
											<logic:notEqual name="row" property="price" value="-1"><c:out value="${row.price}"/></logic:notEqual>
										</c:otherwise>
									</c:choose>
								</td>
								<td align="center">
									<c:choose>
										<c:when test="${not READ_ONLY}">
											<select id="accountFuturePeriodIdSelect" name='instructionsFuturesView[<c:out value="${int_i}"/>].accountFuturePeriodId' class="campo_texto" >							
												<c:forEach var="rowAcc" items="${InstructionPurchaseDetailForm.instructionsFuturesView[int_i].accountPeriod}">
													<option  value='<c:out value="${rowAcc.periodId}" />' <c:if test="${rowAcc.selected}"> selected</c:if> ><c:out value="${rowAcc.periodName}" /></option>
												</c:forEach>
											</select>
										</c:when>
										<c:otherwise>
											<c:forEach var="rowAcc" items="${InstructionPurchaseDetailForm.instructionsFuturesView[int_i].accountPeriod}">
													<c:if test="${rowAcc.selected}">
														<c:out value="${rowAcc.periodName}"/>
													</c:if>
											</c:forEach>
										</c:otherwise>
									</c:choose>
								</td>
								<td align="center">
									<c:choose>
										<c:when test="${not READ_ONLY}">
											<select id="applicationFuturePeriodIdSelect" name='instructionsFuturesView[<c:out value="${int_i}"/>].applicationFuturePeriodId' class="campo_texto" >							
												<c:forEach var="rowApp" items="${InstructionPurchaseDetailForm.instructionsFuturesView[int_i].applicationPeriod}">
													<option  value='<c:out value="${rowApp.periodId}" />' <c:if test="${rowApp.selected}"> selected</c:if>><c:out value="${rowApp.periodName}" /> </option>
												</c:forEach>
											</select>
										</c:when>
										<c:otherwise>
											<c:forEach var="rowApp" items="${InstructionPurchaseDetailForm.instructionsFuturesView[int_i].applicationPeriod}">
													<c:if test="${rowApp.selected}">
														<c:out value="${rowApp.periodName}"/>
													</c:if>
											</c:forEach>
										</c:otherwise>
									</c:choose>	
								</td>
								<td align="center">
									<c:choose>
										<c:when test="${not READ_ONLY}">
											<select id="minorPriceSelect" name='instructionsFuturesView[<c:out value="${int_i}"/>].miniorPrice' class="campo_texto" >
											  	<option value="Y"  <logic:equal name="row" property="miniorPrice" value="Y">selected</logic:equal>><bean:message key="label.common.yes" /></option>
											  	<option value="N"  <logic:equal name="row" property="miniorPrice" value="N">selected</logic:equal>><bean:message key="label.common.no" /></option>
											 </select>
										</c:when>
										<c:otherwise>
											<c:choose>
												<c:when test="${row.miniorPrice eq 'Y'}">
													<bean:message key="label.common.yes" />
												</c:when>
												<c:otherwise>
													<bean:message key="label.common.no" />
												</c:otherwise>
											</c:choose>
										</c:otherwise>
									</c:choose>
								</td>
								<td align="right">	
									<c:choose>
										<c:when test="${not READ_ONLY}">
											<input type="text" id="stopLossQuantity" name='instructionsFuturesView[<c:out value="${int_i}"/>].stopLoss' onfocus="this.select();" value='<logic:notEqual name="row" property="stopLoss" value="-1"><c:out value="${row.stopLoss}"/></logic:notEqual>' style="text-align: right;" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);" class="columnanumero" size="5" />
										</c:when>
										<c:otherwise>
											<c:out value="${row.stopLoss}"/>
										</c:otherwise>
									</c:choose>
								</td>
								<td>
									<c:if test="${not READ_ONLY}">
										<a href="#" onclick='cleanValues("<c:out value="${int_i}"/>")'>
											<img alt="<bean:message key="login.button.clear" />" src="images/erase.png" border="0">
										</a>
									</c:if>
								</td>
							</tr>	
						</logic:iterate>
					</logic:notEmpty>		
				</table>					
			</td>
		</tr>
	</table>
	<br/>
		<table align="center" width="99%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
			<tr>
				<td style="text-align: center; vertical-align: middle; width: 50%" class="columnadatoPar">
					<c:if test="${not READ_ONLY}">
						<html:submit styleClass="boton_large"  property="sendEmail" ><bean:message key="label.common.save.and.sendMail"/></html:submit>
						<html:submit styleClass="boton"><bean:message key="label.common.save"/> </html:submit>						
					</c:if>
					<html:button styleClass="boton" property="backButton" onclick="location.href = 'editInstructionPurchaseHeader.do'"><bean:message key="label.common.cancel"/></html:button> 
				</td>
			</tr>
		</table>	
</html:form>
<script>
	<c:if test="${not READ_ONLY}">
		sumQuantity(document.InstructionPurchaseDetailForm)
	</c:if>
	sumFutures(document.InstructionPurchaseDetailForm);
</script>
